<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title>运营平台</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="renderer" content="webkit">
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge">-->
<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/common.css?v=20170207" />
<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/table.css?v=20170117" />
<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/jquery-ui.css" />
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery-1.11.1.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery-ui.min.js" type="text/javascript"></script>
 <script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/yunIndex.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery-ym-datePlugin-0.1.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/global.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/cheshan/js/common.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery.placeholder.min.js"></script>
<script type="text/javascript">
 $(function(){
     $("input").placeholder();
     if (navigator.userAgent.indexOf("Safari") > -1) {
       $("input").css("lineHeight","normal !important");
     };
});
</script>

<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/cashier.css" />
<body>
<div class="header">
<div class="headerCo">
<span>你好,<?php echo ($user_info["real_name"]); ?><a href="<?php echo (WEB_URL); ?>Emp/logout">退出</a></span>
<h1><img src="<?php echo get_style_cdnurl();?>paimai/yunying/images/yun_logo.jpg"></h1>
</div>
</div>
<div class="mian">
    <div class="mianL">
        <div class="mianL">
    <dl>
        <dd>
            <a id="menu_sy" href="/Index/index" class="shouye">首页</a>
        </dd>
        <?php foreach ($tree_menu as $key => $value): ?>
          <dd>
            <span id="menu_<?php echo ($value['first_char']); ?>" ><img src="<?php echo get_style_cdnurl();?>paimai/yunying/images/yun_jia.jpg"><?php echo ($value['name']); ?></span>
            <ul style="display: none;">
                <?php if (!empty($value['children'])): ?>
                    <?php foreach ($value['children'] as $k => $v): ?>
                        <li><a id='menu_<?php echo ($v["first_char"]); ?>' href="<?php echo ($v['url']); ?>"><?php echo ($v['name']); ?></a></li>
                    <?php endforeach ?>
                <?php endif ?>
            </ul>
        <?php endforeach ?>
    </dl>
</div>

<?php $menu = 'jybggl.bgd'; ?>
<?php $menu=json_encode(explode('.', $menu)); ?>
<script>
    $(function () {
        var cur_menu = '<?php echo ($menu); ?>', cur_menu = eval('[' + cur_menu + ']'), cur_menu = cur_menu[0];
        if (cur_menu == "sy") {
            $("#menu_sy").removeClass('shouye').addClass('current');
        }
        $('#menu_' + cur_menu[0]).click();
        $('#menu_' + cur_menu[0]).find("img").attr("src", "http://img1.isou365.cn/paimai/yunying/images/yun_jie.jpg");
        $(".mianL").css("height", $(document).height() - 95);
        $('#menu_' + cur_menu[1]).addClass('current');
    });
</script>
    </div>
        <div class="mianR">
            <h3 class="yonghu">拍单变更单信息</h3>
            <div class="arbitration">
                <table>
                    <tbody>
                        <tr>
                            <td width="15%">车辆名称</td>
                            <td width="35%"><?php echo ($res["model"]); ?></td>
                            <td width="15%">车辆编号</td>
                            <td width="35%"><?php echo ($res["sno"]); ?></td>
                        </tr>
                        <tr>
                            <td width="15%">变更单号</td>
                            <td width="35%"><?php echo ($res["modify_no"]); ?></td>
                            <td width="15%">拍单号</td>
                            <td width="35%"><?php echo ($res["order_no"]); ?></td>
                        </tr>
                        <tr><td>变更原因</td>
                        <td align="left">
                            <div class="change-reason">
                                    <?php if ($res['source'] < 8): ?>
                                        <input type="radio" checked="checked" name="change_reason" value="3"><label for="testing">买方违约</label>
                                    <?php else: ?>
                                        <input type="radio" checked="checked" name="change_reason" value="4"><label for="testing1">卖方违约</label>
                                    <?php endif ?>
                                    
                                    
                            </div>
                        </td>
                        <td rowspan="2">变更描述</td><td rowspan="2" align="left"><textarea placeholder="描述" class="change-describe" id="change_describe"></textarea></td>
                        </tr>
                        <tr style="border: none;">
                            <td>处理结果</td>
                            <td align="left">
                                <div class="compensate">
                                    <input type="radio" checked="checked" name="change_result" value="2" id="change_result"><label for="Payment">停止交易</label>
                                </div>
                            </td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>             
                        </tr>
                    </tbody>
                </table>
            </div>
            <?php if ($res['source'] < 8): ?>
                <div class="dealerShow">
                    <h3 class="yonghu">车商处理</h3>
                    <div class="arbitration" >
                        <table>
                            <thead><tr><td>关联单据</td><td>费用项</td><td>退/赔项</td><td>收扣款项</td></tr></thead>
                            <tbody>
                                <tr>
                                    <td width="20%">拍单号：<?php echo ($res["order_no"]); ?></td>
                                    <td width="30%">
                                        <span>应收车款：<?php echo ($res["final_price"]); ?>元</span>
                                        <span>实收车款：<span id='real_collection' style='padding:0px;'><?php echo ($res["real_collection"]); ?></span>元</span>
                                    </td>
                                    <td width="30%">应退车款：<?php echo ($res["real_collection"]); ?>元</td><td width="20%"></td>
                                </tr>
                                <tr>
                                    <td>赔款</td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>违约扣款</td>
                                    <td></td>
                                    <td></td>
                                    <td>
                                        <span class="cash-money">
                                            <input type="text" name="voucher" id="voucher" onkeyup="this.value=this.value.replace(/\D/g,'')" /><label for="voucher1">元</label>
                                        </span>
                                    </td>
                                </tr>
                                <tr>
                                    <td>小计</td>
                                    <td></td>
                                    <td><span id="real_coll"><?php echo ($res["real_collection"]); ?></span>元</td>
                                    <td><span id="dealer_total"></span>元</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div id="finance_fee" class="financial" ></div>
                <script>
                    $(function(){
                        $("#dealer_total").html(0);
                        var money = parseInt($("#real_coll").html());
                        if (money>0) {
                            $('#refund').show();
                        };
                        $('#finance_fee').html("财务退款："+money+"元");
                        $("#voucher").keyup(function(){
                            if(parseInt($(this).val())>2000){
                                $(this).val($(this).val().substring(0,3));
                            }                           
                            if($(this).val()==""){
                                var cash=0;
                                $("#dealer_total").html(cash);
                                $('#finance_fee').html("财务退款："+money+"元");
                                if (money>0) {
                                    $('#refund').show();
                                };
                            }else{
                                var cash=parseInt($(this).val());
                                $("#dealer_total").html(cash);
                                var all_money = money-cash;
                                if (all_money > 0) {
                                    $('#finance_fee').html("财务退款："+all_money+"元");
                                    $('#refund').show();
                                }else{
                                    $('#finance_fee').html("财务收款："+Math.abs(all_money)+"元");
                                    $('#refund').hide();
                                }
                            }                       
                        })
                    })
                </script>
            <?php endif ?>
            <!-- 车商处理 -->
            <?php if ($res['source'] > 7): ?>
                <div class="ownerShow">
                    <h3 class="yonghu">车商处理</h3>
                    <div class="arbitration" >
                        <table>
                            <thead><tr><td>关联单据</td><td>费用项</td><td>退/赔项</td><td>收扣款项</td></tr></thead>
                            <tbody>
                                <tr>
                                    <td width="20%">拍单号：<?php echo ($res["order_no"]); ?></td>
                                    <td width="30%">
                                        <span>应收车款：<?php echo ($res["final_price"]); ?>元</span>
                                        <span>实收车款：<span id='real_collection_two' style='padding:0px;'><?php echo ($res["real_collection"]); ?></span>元</span>
                                    </td>
                                    <td width="30%">应退车款：<?php echo ($res["real_collection"]); ?>元</td><td width="20%"></td>
                                </tr>
                                <tr>
                                    <td>赔偿</td>
                                    <td></td>
                                    <td>
                                        <span class="cash-money">
                                        <input type="text" name="voucher_two" id="voucher_two" onkeyup="this.value=this.value.replace(/\D/g,'')" /><label for="voucher1">元</label>
                                        </span>
                                    </td>
                                    <td></td>
                                </tr>
                                <tr><td>违约扣款</td><td></td><td></td><td></td></tr>
                                <tr>
                                    <td>小计</td>
                                    <td></td>
                                    <td><span id="dealer_total_two"></span>元</td>
                                    <td></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div id="finance_fee_two" class="financial"></div>

                 <script>
                    $(function(){
                        var payments=parseInt($("#real_collection_two").html());
                        $("#dealer_total_two").html(payments);
                        if (payments > 0) {
                            $('#refund').show();
                        };
                        $('#finance_fee_two').html("财务退款："+payments+"元");
                        $("#voucher_two").keyup(function(){
                            if(parseInt($(this).val())>2000){
                                $(this).val($(this).val().substring(0,3));
                            }                      
                            if($(this).val()==""){
                                var cash=0;
                                var total=payments+cash;
                                $("#dealer_total_two").html(total);
                                if (total > 0) {
                                    $('#refund').show();
                                };
                                $('#finance_fee_two').html("财务退款："+total+"元");
                            }else{
                                var cash=parseInt($(this).val());
                                var total=payments+cash;
                                $("#dealer_total_two").html(total);
                                if (total > 0) {
                                    $('#refund').show();
                                };
                                $('#finance_fee_two').html("财务退款："+total+"元");
                            }                       
                        })
                    })
                </script>                
                    
            <?php endif ?>
            <div class="refund" id="refund" style="margin-bottom:15px;display:none;">
                <h3>买方收款账号</h3>
                <ul class="clearfix">
                    <li><span>开户名：</span><input type="text" value="" name="account_name" /></li>
                    <li><span>银行帐号：</span><input type="text" value="" name="bank_account" /></li>
                    <li><span>银行名称：</span><input type="text" value="" name="bank_name"></li>
                </ul>
            </div>
            <?php if ($res['source'] > 7): ?>
                <h3 class="yonghu">车主处置</h3>
                <div class="arbitration">
                    <table>
                        <thead><tr><td>关联单据</td><td>费用项</td><td>退/赔项</td><td>收扣款项</td></tr></thead>
                        <tbody>
                            <tr>
                                <td width="20%">采购单号：<?php echo ($res["purchase_order_nu"]); ?></td>
                                <td width="30%">
                                    <span>应付车款：<?php echo ($res["success_price"]); ?>元</span>
                                    <span>实付车款：<span id='real_payment' style='padding:0px;'><?php echo ($res["real_payment"]); ?></span>元</span>
                                </td>
                                <td width="30%"></td>
                                <td width="20%">收回车款：<?php echo ($res["real_payment"]); ?>元</td>
                            </tr>
                            <tr><td>赔偿</td><td></td><td></td><td></td></tr>
                            <tr>
                                <td>违约扣款</td>
                                <td></td>
                                <td></td>
                                <td>
                                    <span class="cash-money">
                                        <input type="text" name="voucher_three" id="voucher_three" onkeyup="this.value=this.value.replace(/\D/g,'')" /><label for="voucher1">元</label>
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td>小计</td>
                                <td></td>
                                <td></td>
                                <td><span id="owner_total"></span>元</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div id="finance_fee_three" class="financial"></div>
                <script>
                    $(function(){
                        var back_money = parseInt($('#real_payment').html());
                        $('#finance_fee_three').html("财务收款："+back_money+"元");
                        // var payments=parseInt($("#real_payment").html());
                        $("#owner_total").html(back_money);
                        $("#voucher_three").keyup(function(){
                            if(parseInt($(this).val())>2000){
                                $(this).val($(this).val().substring(0,3));
                            }                          
                            if($(this).val()==""){
                                var cash=0;
                                var total = cash + back_money;
                                $("#owner_total").html(total);
                                $('#finance_fee_three').html("财务收款："+total+"元");
                            }else{
                                var cash=parseInt($(this).val());
                                var total = cash + back_money;
                                $("#owner_total").html(total);
                                $('#finance_fee_three').html("财务收款："+total+"元");
                               
                            }                       
                        })
                    })
                </script>                
            <?php endif ?>

            <div class="yongBtn clearfix">
                <input type="hidden" name="first_money" value="">
                <input type="submit" value="提交" class="queding">
                <input class="quxiao" type="submit" value="返回" onclick="history.go(-1)">
            </div>
        </div>        
    <div class="clear"></div>
</div>
<script>
    $(".queding").click(function(){
        var change_reason = $('input[name="change_reason"]:checked').val();
        if (change_reason < 1) {
            shibai_alert1('请选择变更原因');
            return;
        };
        var change_result = $('input[name="change_result"]:checked').val();
        if (change_result < 1) {
            shibai_alert1('请选择处理结果');
            return;
        };
        var change_describe = $('#change_describe').val(); 
        
        var account_name = $('input[name="account_name"]').val(); //开户名
        var bank_account = $('input[name="bank_account"]').val(); //银行账号
        var bank_name =  $('input[name="bank_name"]').val(); //银行名称
        // if (account_name =='' || bank_account =='' || bank_name =='') {
        //     shibai_alert1('收款账号信息不全');
        //     return;
        // };
        var param = {
            'modify_reason':change_reason, //变更原因
            'modify_result':change_result, //变更结果
            'modify_desc':change_describe, //变更描述
            'account_name':account_name,
            'bank_account':bank_account,
            'bank_name':bank_name
        }
        var source = <?php echo ($res["source"]); ?>;
        if (source < 8) {
            var payment_amount = $('#voucher').val();
            if (payment_amount == '') {
                shibai_alert1('金额不能为空');
                return;
            };
            if (payment_amount > 2000) {
                shibai_alert1('金额不能大于2000元');
                return;
            };
            var real_collection = $('#real_collection').html();
            if ((real_collection - payment_amount) >0 ) {
                if (account_name =='' || bank_account =='' || bank_name =='') {
                    shibai_alert1('收款账号信息不全');
                    return;
                };
            };
            param.payment_amount = payment_amount;
            var url = "/ChangeOrder/dealerDeal/mid/<?php echo ($res["mid"]); ?>";
        }else{
            var payment_amount = $('#voucher_two').val();
            var real_collection = $('#real_collection_two').html();
            if (real_collection+payment_amount > 0) {
                if (account_name =='' || bank_account =='' || bank_name =='') {
                    shibai_alert1('收款账号信息不全');
                    return;
                };
            };
            if (payment_amount == '') {
                shibai_alert1('金额不能为空');
                return;
            };
            if (payment_amount > 2000) {
                shibai_alert1('金额不能大于2000元');
                return;
            };
            param.payment_amount = payment_amount;
            var owner_payment_amount = $('#voucher_three').val();
            if (owner_payment_amount == '') {
                shibai_alert1('金额不能为空');
                return;
            };
            if (owner_payment_amount > 2000) {
                shibai_alert1('金额不能大于2000元');
                return;
            };
            param.owner_payment_amount = owner_payment_amount;
            var url = "/ChangeOrder/ownerDeal/mid/<?php echo ($res["mid"]); ?>";
        };
        var btn_obj = $(this);
        btn_obj.val("提交中...").attr("disabled", 'disabled');
        $.post(url,param, function(data){
            if (data.code == 200) {
                delay_alert(data.msg, 300);
                setTimeout(function () {
                    btn_obj.val("提交").removeAttr("disabled style");
                    window.location.href ='/ChangeOrder/index';
                }, 400);
            }else{
                btn_obj.val("提交").removeAttr("disabled style");
                delay_alert(data.msg, 300);
            }
        },"json");
    })
</script>
</body>
</html>